<div style="padding: 20px;">
    <form id="from" class="layui-form" action="/os/edit">

        <div class="layui-form-item">
            <label class="layui-form-label">应用类型</label>

            <div class="layui-input-block">

                <?php $pid = isset($info['parent_id'])?$info['parent_id']:'0'?>
                <?php foreach($cates as $i=>$item):?>

                <?php if($pid>0):?>

                <input type="radio" name="cate"  <?php echo $pid==$item['id']?"checked":""?>
                value="<?php echo $item['id']?>" title="<?php echo $item['name']?>">

                <?php else:?>

                <input type="radio" name="cate"  <?php echo $i=='0'?"checked":""?> value="<?php echo $item['id']?>"
                title="<?php echo $item['name']?>">

                <?php endif;?>


                <?php endforeach;?>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">应用名称</label>

            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="title"
                       value="<?php echo isset($info['name'])?$info['name']:''?>" autocomplete="off"
                       placeholder="请输入应用名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">应用简写</label>

            <div class="layui-input-inline">
                <input type="text" name="type" lay-verify="title"
                       value="<?php echo isset($info['type'])?$info['type']:''?>" autocomplete="off"
                       placeholder="请输入应用简写" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>

            <div class="layui-input-block">
                <textarea name="des" placeholder="请输入备注内容"
                          class="layui-textarea"><?php echo isset($info['remark'])?$info['remark']:''?></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form'], function () {
        var form = layui.form()
                , layer = layui.layer

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 2) {
                    return '标题至少得3个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
//            layer.alert(JSON.stringify(data.field), {
//                title: '最终的提交信息'
//            })

            var data = {
                parent_id: $("input[name='cate']").val(),
                title: $("input[name='name']").val(),
                type: $("input[name='type']").val(),
                remark: $("textarea[name='des']").val()
            }
            //console.log(data);return;
            $.post("/os/edit<?php echo isset($info['id'])?'?id='.$info['id']:''?>", data, function (d) {
                parent.window.location.reload();
            });
            return false;
        });

    });
</script>